from moviepy.editor import *
from moviepy.video.tools.segmenting import color_split

# 1. 基础参数
W, H = 1080, 1920  # 竖版9:16尺寸
BG_COLOR = "#FFFFFF"  # 白底
DURATION = 15  # 视频总时长(秒)

# 2. 创建画布
clip = ColorClip(size=(W, H), color=hex_to_rgb(BG_COLOR), duration=DURATION)

# 3. 添加文字层（关键人设信息）
texts = [
    TextClip(
        "前饿了么/贝壳技术总监", fontsize=80, color="#FF6B00", font="PingFang-SC-Bold"
    )
    .set_position(("center", H * 0.3))
    .set_duration(3),
    TextClip(
        "5年打造20万粉丝IP", fontsize=70, color="#4285F4", font="PingFang-SC-Medium"
    )
    .set_position(("center", H * 0.4))
    .set_duration(3),
    TextClip("加微信 jeff ARC", fontsize=90, color="#EA4335", font="PingFang-SC-Heavy")
    .set_position(("center", H * 0.6))
    .set_duration(5),
]

# 4. 添加动态进度条（模拟播客播放）
progress_bar = ColorClip(
    size=(W * 0.8, 10), color=hex_to_rgb("#4285F4"), duration=DURATION
)
progress_animation = progress_bar.set_position(lambda t: ("center", H * 0.8 - 5 * t))

# 5. 合成所有元素
final_clip = CompositeVideoClip([clip, *texts, progress_animation])

# 6. 导出视频
final_clip.write_videofile("podcast_promo.mp4", fps=24, threads=4)
